<?php

namespace app\admin\command;

use app\admin\model\Reserve;
use app\admin\model\Room;
use app\admin\model\User;
use app\common\library\Yunding;
use Carbon\Carbon;
use fast\Random;
use think\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;
use think\Db;
use think\Env;
use think\Exception;
use think\Log;

class UpdateNickname extends Command
{

    protected function configure()
    {
        $this->setName('updatenickname')
            ->setDescription('update nickname');
    }

    protected function execute(Input $input, Output $output)
    {
        @ini_set("memory_limit",'-1');
        $stime=microtime(true);

        $users = User::where('nickname', '微信用户')
            ->select();

        foreach ($users as $user) {
            echo $user->nickname;
            $user->nickname = 'user_' . date('ymd', $user->jointime) . Random::alnum(6);
            $user->save();
        }


        $etime=microtime(true);//获取程序执行结束的时间
        $total=$etime-$stime;   //计算差值
        $output->writeln($total);
    }

}
